﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GpyOperation.aspx.cs" Inherits="Office_GpyOperation" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<script language="javascript">
    var nFileCount = 0;
    var bAdjustMode = 0;
    var bCropArea = 0;
    var bSeriesCapture = 0;
    var bReadBarCode = 0;
    var bSetDenoise = 0;
    var Width = 0;
    var Height = 0;
    var strFile = "";
    var index = 0;
    var strCardFile;
    var cardIndex = 0;
    var iid = "<%=Request["iid"]%>";
    function Capture() {
        //var obj = document.getElementById("FileType");
        //var index = obj.selectedIndex;
        // strFile = "d:\\test\\Img" + nFileCount;
        //if (index == 0) {
        //    strFile += ".bmp";
        //}
        //if (index == 1) {
        //    strFile += ".jpg";
        //}
        //if (index == 2) {
        //    strFile += ".tif";
        //}
        //if (index == 3) {
        //    strFile += ".png";
        //}
        strFile = "c:\\temp\\"+iid+"\\Img" + nFileCount + ".jpg";

        CmCaptureOcx.CaptureImage(strFile);
        nFileCount++;

        document.getElementById("Updata").disabled = false;
        $("#spanMsg").html("拍照成功，当前是第"+nFileCount+"张照片");
    }

    function UpdataFile() {
        var strRoot = Common.GetRootPath();
        var striid = request("iid");
        var strUserId = request("UserId");
        var strStep = request("step");
        var filename = strFile.replace("c:\\temp\\"+iid+"\\", "");
        var Url = strRoot + "/Office/GpyProcess.ashx?IID=" + striid + "&UserId=" + strUserId + "&step=" + strStep + "&filename=" + filename;
        CmCaptureOcx.UpdataFile(Url, strFile, 0);

        $("#spanMsg").html("上传成功第" + nFileCount + "个图片：" + filename);
    }


    function AddDevice() {
        var i = 0;
        var total = CmCaptureOcx.GetDevCount();
        for (i = 0 ; i < total ; i++) {
            var DevEle = CmCaptureOcx.GetDevFriendName(i);
            Reso.DeviceName.options[i].text = DevEle;
        }
    }

    function StartVideo() {
        //if (CmCaptureOcx != null || typeof (CmCaptureOcx) != "undefined") {
        //    CmCaptureOcx.EndVideo();
        //    CmCaptureOcx.Destory();
        //}
        CmCaptureOcx.Initial();
        CmCaptureOcx.StartRun(index);
        //AddResolution2Comb(Reso);
        //SetResolution();
        //SetFileType();

        document.getElementById("Destory").disabled = false;
        document.getElementById("Capture").disabled = false;
    }

    function ViewFiles() {
        var striid = request("iid");
        window.open("GpyUploadFilesBroswe.aspx?iid=" + striid);
    }
</script>
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="../ScriptFile/jquery.js"></script>
    <script src="../ScriptFile/Common/Jquery.Common.js"></script>
    <script src="../ScriptFile/RequestParams.js"></script>
    <title>高拍仪操作</title>


    <script type="text/javascript" for="CmCaptureOcx" event="GetImageFileName(fileName);">
        CmCaptureOcx.AddPDFImageFile(fileName);
    </script>

    <script type="text/javascript" for="CmCaptureOcx" event="GetRButtonDownPoint(x,y);">
        alert(x);
    </script>
</head>
<body>
    <div style="text-align: center">
        <p>
            <object id="CmCaptureOcx" style="margin-left: 5px; width: 52.4%; height: 80%"
                classid="clsid:3CA842C5-9B56-4329-A7CA-35CA77C7128D">
            </object>
        </p>
        <span id="spanMsg" style="color: red">请先点击打开摄像头启动拍照窗口,然后点击拍照。</span>
    </div>
    <div style="text-align: center">
        <input type="button" value="打开摄像头" onclick="StartVideo();" name="start" id="start">
        <input type="button" value="关闭摄像头" onclick="CmCaptureOcx.Destory();" name="Destory" id="Destory" disabled="true">
        <input type="button" value=" 拍    照 " onclick="Capture();" name="Capture" id="Capture" disabled="true">
        <br />
        <br />

        <input type="button" value=" 文件上传 " onclick="UpdataFile();" name="Updata"  disabled="true"/>
        <input type="button" value=" 查看上传文件 " onclick="ViewFiles();" name="btnViewFiles" />
    </div>
</body>
</html>
